package com.dqhl.community.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.dqhl.community.R;
import com.dqhl.community.base.BaseActivity;

/**
 * Created by guanluocang on 2016/8/29.
 * 物业缴费支付Activity
 */
public class PropertyConfimActivity extends BaseActivity implements View.OnClickListener {

    private TextView tv_topTitle;
    private ImageView iv_topBack;
    private Button btn_payConfim;//确认支付按钮
    private RadioGroup rg_property;
    private RadioButton rb_weixin, rb_alipay;
    private String payment_method = "";
    private TextView tv_money;
    private TextView tv_total;
    private String strMoney;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_property_confim);
        // 实例化对象
        initView();
        // 实例化数据
        initData();
    }

    // 实例化数据
    private void initData() {
        tv_topTitle.setText(R.string.property_type);
        btn_payConfim.setOnClickListener(this);
        iv_topBack.setOnClickListener(this);
    }

    // 实例化对象
    private void initView() {
        strMoney = getIntent().getStringExtra("total");

        tv_topTitle = (TextView) findViewById(R.id.tv_top_title);
        iv_topBack = (ImageView) findViewById(R.id.iv_top_back);
        iv_topBack.setVisibility(View.VISIBLE);
        btn_payConfim = (Button) findViewById(R.id.btn_payConfim);
        rg_property = (RadioGroup) findViewById(R.id.radioGroup);
        rb_weixin = (RadioButton) findViewById(R.id.rb_weixin);
        rb_alipay = (RadioButton) findViewById(R.id.rb_alipay);
        tv_money = (TextView) findViewById(R.id.tv_money);
        tv_money.setText("￥" + strMoney);
        tv_total = (TextView) findViewById(R.id.tv_total);
        tv_total.setText("￥" + strMoney);

        rg_property.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                switch (i) {
                    case R.id.rb_weixin:
                        payment_method = "1";
                        break;
                    case R.id.rb_alipay:
                        payment_method = "2";
                        break;
                }
            }
        });
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_top_back:
                finish();
                break;
            case R.id.btn_payConfim:
                propertyConfim();
                overlay(PayRecordActivity.class);
                break;
        }
    }

    //确认支付
    public void propertyConfim() {
        if ("1".equals(payment_method)) {
            //微信支付

        } else if ("2".equals(payment_method)) {
            //支付宝支付
        }
    }
}
